From 83dd050ab23a57f4b7ad614b6b3f5a82c21152e9 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 3 Mar 2014 20:46:10 +0100 Subject: [PATCH] gesture: Add private getter to know whether a touch begin was handled If GDK_TOUCH_BEGIN was handled/consumed for a sequence, or GDK_BUTTON_PRESS was handled for the mouse gesture, this function will return TRUE. --- gtk/Makefile.am | 1 + gtk/gtkgesture.c | 29 +++++++++++++++++++++++++++-- gtk/gtkgestureprivate.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 gtk/gtkgestureprivate.h diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 8e69e5e016..b48a1c926d 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -509,6 +509,7 @@ gtk_private_h_sources = \ gtkfilesystemmodel.h \ gtkfontchooserprivate.h \ gtkfontchooserutils.h \ + gtkgestureprivate.h \ gtkheaderbarprivate.h \ gtkhslaprivate.h \ gtkiconcache.h \ diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c index e86e6d4f0b..1014e12b01 100644 --- a/gtk/gtkgesture.c +++ b/gtk/gtkgesture.c @@ -45,6 +45,7 @@ enum { struct _PointData { GdkEvent *event; + guint press_handled : 1; guint state : 2; }; @@ -301,8 +302,14 @@ gtk_gesture_handle_event (GtkEventController *controller, break; /* Fall through */ case GDK_TOUCH_BEGIN: - if (_gtk_gesture_update_point (gesture, event, TRUE)) - _gtk_gesture_check_recognized (gesture, sequence); + if (_gtk_gesture_update_point (gesture, event, TRUE) && + _gtk_gesture_check_recognized (gesture, sequence)) + { + PointData *data; + + data = g_hash_table_lookup (priv->points, sequence); + data->press_handled = TRUE; + } break; case GDK_BUTTON_RELEASE: if (priv->touch_only) @@ -1021,3 +1028,21 @@ gtk_gesture_cancel_sequence (GtkGesture *gesture, _gtk_gesture_remove_point (gesture, data->event); return TRUE; } + +gboolean +_gtk_gesture_handled_sequence_press (GtkGesture *gesture, + GdkEventSequence *sequence) +{ + GtkGesturePrivate *priv; + PointData *data; + + g_return_val_if_fail (GTK_IS_GESTURE (gesture), FALSE); + + priv = gtk_gesture_get_instance_private (gesture); + data = g_hash_table_lookup (priv->points, sequence); + + if (!data) + return FALSE; + + return data->press_handled; +} diff --git a/gtk/gtkgestureprivate.h b/gtk/gtkgestureprivate.h new file mode 100644 index 0000000000..d60eaf10d5 --- /dev/null +++ b/gtk/gtkgestureprivate.h @@ -0,0 +1,32 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2014, Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see . + * + * Author(s): Carlos Garnacho + */ + +#ifndef __GTK_GESTURE_PRIVATE_H__ +#define __GTK_GESTURE_PRIVATE_H__ + +#include "gtkgesture.h" + +G_BEGIN_DECLS + +gboolean _gtk_gesture_handled_sequence_press (GtkGesture *gesture, + GdkEventSequence *sequence); + +G_END_DECLS + +#endif /* __GTK_GESTURE_PRIVATE_H__ */ -- 2.30.2